<?php
define('DEBUG', 'on');
define('WEBPATH', realpath(__DIR__ . '/../'));
require dirname(__DIR__) . '/libs/lib_config.php';
//设置PID文件的存储路径
Swoole\Network\Server::setPidFile(__DIR__ . '/app_server.pid');

/**
 * 显示Usage界面
 * php app_server.php start|stop|reload
 */
Swoole\Network\Server::start(function ()
{

    $server = Swoole\Protocol\WebServer::create(__DIR__ . '/swoole.ini');
    $server->setAppPath(WEBPATH . '/apps/');                                 //设置应用所在的目录
    $server->setDocumentRoot(WEBPATH);
    $log = new \Swoole\Log\FileLog(array(
        'type' => 'FileLog',
        'enable_cache' => false,
        'archive'=>true,
        'file' => WEBPATH . '/logs/access.log',
    ));

    $server->setLogger($log); //Logger
    //$server->daemonize();
    //                                              //作为守护进程
   // \Swoole::$php->event->runWorker(2);
    $server->run(array('worker_num' => 4, 'max_request' => 5000));

});

